<?php
	class Activity extends Model_Abstract{
		
		public function getRecentActivities($siteid){
			try{
				$sql = "select * from activities where site=? order by time desc limit 5";
				$result = $this->_connection->query($sql,array($siteid));
				return $result;
			}catch (Exception $e){
				QLog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), QLog::ERR);
				throw new Model_Exception($e->getMessage(), $e->getCode());
			}
		}
		
		public function addActivity($who, $what, $siteid){
			try{
				$sql = "insert into activities set time=?, who=?, what=?, site=?";
				$result = $this->_connection->execute($sql,array(time(),$who, $what, $siteid));
				return $result;
			}catch (Exception $e){
				QLog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), QLog::ERR);
				throw new Model_Exception($e->getMessage(), $e->getCode());
			}
		}
		
		
	}